package com.tlxch.controller.teacher;

import com.tlxch.dto.StuAvgdto;
import com.tlxch.dto.TScGradedto;
import com.tlxch.dto.TStudto;
import com.tlxch.pojo.ScGrades;
import com.tlxch.result.PageResult;
import com.tlxch.result.Result;
import com.tlxch.server.teacher.TScGradesService;
import com.tlxch.vo.Gradesvo;
import com.tlxch.vo.StuAvgvo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "课程成绩相关接口")
@Slf4j
@RestController
@RequestMapping("/teacher/tscgrades")
public class TScGradesController {
    @Autowired
    TScGradesService tScGradesService;

    @PutMapping("/upstugrade")
    @ApiOperation("添加学生成绩")
    public Result upStuGrade(@RequestBody ScGrades scGrades){
        tScGradesService.upStuGrade(scGrades);
        return Result.success();
    }

    @GetMapping("/getstugrade")
    @ApiOperation("学生课程成绩分页查询")
    public Result<PageResult> getStuList(TScGradedto tScGradedto){
        PageResult pageResult = tScGradesService.pageQuery(tScGradedto);
        return Result.success(pageResult);
    }

    @GetMapping("/getstugradebyid")
    @ApiOperation("计算学生当前学前平均成绩")
    public Result<StuAvgvo> getStuAvg(StuAvgdto stuAvgdto){
        StuAvgvo stuAvgvo = tScGradesService.getStuAvg(stuAvgdto);
        return Result.success(stuAvgvo);
    }

    @GetMapping("/getstugradebysid")
    @ApiOperation("根据学号查询学生课程成绩")
    public Result<Gradesvo> getstuGradeByciAndsid(String sid, String cid){
        Gradesvo scGrades = tScGradesService.getstuGradeByciAndsid(sid,cid);
        return Result.success(scGrades);
    }
}
